{layout name="layout" /}

<div class="Hui-article">
    <article class="cl pd-20">
        <!-- <form action="" method="post" class="form form-horizontal" id="form-banner" enctype="multipart/form-data">
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">栏目 banner 图：</label>
                <div class="formControls col-xs-8 col-sm-3">
                    <input type="file" class="input-text" value="" id="upload_file" name="upload_file">
                    <span class="c-red">* 不添加则使用通用 banner 图</span>
                    <input class="btn btn-primary radius" type="button" onCLick="uploadBanner()" value="&nbsp;&nbsp;上传&nbsp;&nbsp;">
                </div>
                <div class="formControls col-xs-8 col-sm-7">
                    <img id="showimg" height="100px">
                </div>
                <div class="col-3"> </div>
            </div>
        </form> -->
        <form action="" method="post" class="form form-horizontal" id="form-category-add">
            <input type="hidden" value="" id="banner" name="banner">
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">
                    <span class="c-red">*</span>上级栏目：</label>
                <div class="formControls col-xs-8 col-sm-3">
                    <span class="select-box">
                        <select class="select" id="sel_Sub" name="pid">
                                <option value="0" {eq name='data.pid' value="0"}selected{/eq}>--请选择分类--</option>
                                {foreach $top as $key=>$value}
                                <option value="{$key}" {eq name='key' value="$data.pid"}selected{/eq}>{$value}</option>
                                {php}$data_cate=model('category')->getCateNamesFP($key);{/php} {notempty name="data_cate"} {foreach $data_cate as $k=>$val}
                                <option value="{$k}" {eq name='k' value="$data.pid"}selected{/eq}>&nbsp;&nbsp;&nbsp;&nbsp;└ {$val}</option>
                                {/foreach} {/notempty} {/foreach}
                        </select>
                    </span>
                </div>
                <div class="col-3"> </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">
                    <span class="c-red">*</span>栏目名称：</label>
                <div class="formControls col-xs-8 col-sm-3">
                    <input type="text" class="input-text" value="{$data.name}" placeholder="请填写栏目名称" id="name" name="name">
                </div>
                <div class="col-3"> </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">
                    <span class="c-red">*</span>栏目模板：</label>
                <div class="formControls col-xs-8 col-sm-3">
                    <span class="select-box">
                        <select class="select" id="sel_Sub" name="tpl_id">
                            <option value="0">--请选择模板--</option>(不选则为默认为单页)
                            <option value="1" {eq name="data.template" value="1"}selected{/eq}>--资讯--</option>
                            <option value="2" {eq name="data.template" value="2"}selected{/eq}>--test--</option>
                        </select>
                    </span>
                </div>
                <div class="col-3"> </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">排序</label>
                <div class="formControls col-xs-8 col-sm-1">
                    <input type="text" class="input-text" value="{$data.sort}" name="sort" style="width:60px;">
                </div>
                <div class="col-3"> </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">
                    <span class="c-red">*</span>是否启用：</label>
                <div class="formControls col-xs-8 col-sm-2 skin-minimal">
                    <div class="radio-box">
                        <input name="status" type="radio" id="sex-1" value="1" {eq name='data.status' value='1' }checked{/eq}>
                        <label for="sex-1">启用</label>
                    </div>
                    <div class="radio-box">
                        <input name="status" type="radio" id="sex-2" value="2" {eq name='data.status' value='2' }checked{/eq}>
                        <label for="sex-2">不启用</label>
                    </div>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">描述：</label>
                <div class="formControls col-xs-8 col-sm-5">
                    <textarea name="description" cols="" rows="" class="textarea" placeholder="说点什么...最多输入100个字符" datatype="*10-100" dragonfly="true"
                        nullmsg="备注不能为空！" onKeyUp="textarealength(this,200)">{$data.description}</textarea>
                    <p class="textarea-numberbar">
                        <em class="textarea-length">0</em>/200</p>
                </div>
                <div class="col-3"> </div>
            </div>
            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <input class="btn btn-success radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                    <input class="btn btn-default radius" type="button" value="&nbsp;&nbsp;返回&nbsp;&nbsp;" onclick="window.history.back();">
                </div>
            </div>
        </form>
    </article>
</div>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
    $(function () {
        $("#form-category-add").submit(function () {
            var note = $("#description").val();

            if (!$("#name").val()) {
                layer.msg('栏目名不能为空!', {
                    icon: 5,
                    time: 1000
                });
                return false;
            }

            if (getblen(note) > 200) {
                layer.msg('备注过长', {
                    icon: 5,
                    time: 1000
                });
                return false;
            }
        })
    })
</script>
<!--请在上方写此页面业务相关的脚本-->